<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class IndexController extends Controller
{
    //
    public function index()
    {
    	$category = DB::table('shop_type') -> where('id', '>', '1') -> get();
    	$data[0] = DB::table('shop_goods') -> where('tid', '=', '3' ) -> get();
    	$data[1] = DB::table('shop_goods') -> where('tid', '=', '4' ) -> get();
    	return view('home.index.index', ['data' => $data, 'category' => $category, 'title' => '主页']);
    }

    // 搜索
    public function search(Request $request)
    {
    	$arr = $request -> all();
    	$keywords = $arr['key'];
    	$data = DB::table('shop_goods') -> where('gname', 'like', '%'.$keywords.'%') -> get();
    	dd($data);
    	return view('home.shop_goods.index', ['data' => $data,'title' => '主页']);
    }
}
